package com.ecmcloud.resource;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ecmcloud.common.dto.Result;
import com.ecmcloud.service.IMenuService;
import com.ecmcloud.vo.MenuVO;
import com.ecmcloud.vo.RouteVO;

/**
 * <p>
 * 菜单管理 前端控制器
 * </p>
 */
@RestController
@RequestMapping(value = {"menu","api/menu"})
public class MenuResource {

	@Autowired
    private IMenuService menuService;


    /**
     * 路由列表
     *
     * @return
     */
    @GetMapping("routes")
    public Result<List<RouteVO>> routes() {
        return menuService.routes();
    }
    
    /**
     * 菜单树形列表
     *
     * @return
     */
    @GetMapping("treeAll")
    public Result<List<MenuVO>> treeAll(String keywords,Integer status) {
        return menuService.treeAll(keywords, status);
    }
    
    /**
     * 创建菜单
     * @param menuVO
     * @return
     */
    @PostMapping("create")
    public Result<String> create(@RequestBody MenuVO menuVO){
        return menuService.create(menuVO);
    }
    
    /**
     * 编辑菜单
     * @param menuVO
     * @return
     */
    @PutMapping("edit")
    public Result<String> edit(@RequestBody MenuVO menuVO){
        return menuService.edit(menuVO);
    }
    
    /**
     * 删除菜单
     * @param menuVO
     * @return
     */
    @DeleteMapping("delete")
    public Result<String> delete(@RequestBody MenuVO menuVO){
        return menuService.delete(menuVO);
    }
}
